<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let main = (config)=>{
            // 我们需要判断参数传进来了没
            // 1.传统写法
            // const dbHost = config && config.db && config.db.username
            // 2.可选链操作符写法
            const dbHost = config?.db?.username
        }

        main({
            db:{
                host:'192.168.1.1',
                username:'root'
            }
        })
    </script>
</body>
</html>